<template>
  <div class="width-100">
    <el-input v-if="variable.type === 'string'" v-model="variable.value" size="mini" class="width-100"
              placeholder="请输入变量默认值" @input="forceUpdate"></el-input>
    <el-input-number v-else-if="['int', 'double'].includes(variable.type)" v-model="variable.value"
                     size="mini" class="width-100"
                     placeholder="请输入变量默认值" @input="forceUpdate"></el-input-number>
    <el-select v-else-if="variable.type === 'bool'" v-model="variable.value" size="mini" class="width-100"
               @change="forceUpdate">
      <el-option label="是" :value="true"></el-option>
      <el-option label="否" :value="false"></el-option>
    </el-select>
    <el-input type="textarea" v-else-if="['list', 'map'].includes(variable.type)" v-model="variable.value"
              size="mini" class="width-100"
              placeholder="请输入变量默认值" @input="forceUpdate"></el-input>
    <el-input v-else v-model="variable.value" size="mini" placeholder="请输入变量默认值" class="width-100"
              @input="forceUpdate"></el-input>
  </div>
</template>

<script>
  export default {
    name: "VariableComponent",
    props: {
      variable: {
        type: Object,
        default: () => {
          return {};
        }
      }
    },
    methods: {
      forceUpdate() {
        this.$forceUpdate()
        this.$emit('changeState')
      }
    }
  }
</script>

<style scoped>

</style>
